<template>
  <div :id="id" style="width: 100%;height: 270px;"></div>
</template>

<script>
    // import Echarts from '../../../../utils/echarts.min.js'
    export default {
      props: ['id', 'options'],
      data(){
        return {
          myChart: null,
        }
      },
      watch: {
        options: {
          handler(newVal, oldVal) {
            if (this.myChart) {
              this.getEchartsData()
            }
          },
          deep: true
        }
      },
      methods:{
        // 折线图数据渲染
        getEchartsData() {
          this.myChart = this.$echarts.init(document.getElementById(this.id))
          this.myChart.setOption(this.options,true);

        }
      },
      mounted() {
        this.$nextTick(() => {
          this.getEchartsData()
        })
      }
    }
</script>

<style>
</style>
